package com.qf.controller;

import com.qf.entity.Order; // 修正实体类名（首字母大写）
import com.qf.service.OrderService;
import com.qf.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @GetMapping("/findAllOrder")
    public R findAllOrder(
            @RequestParam("userId") Integer userId,
            @RequestParam(required = false) String productName,
            @RequestParam(required = false) String startTime,
            @RequestParam(required = false) String endTime,
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "10") Integer pageSize

    ) {
        List<Order> orders = orderService.selectOrdersByUserId(userId);
        System.out.println(userId);
        System.out.println(orders);
        return R.ok(orders);
    }
}